package com.lms.listener;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

public class DataRollbackListener implements ServletContextListener {
    private DataRollbackThread dataRollbackThread;
    @Override
    public void contextInitialized(ServletContextEvent servletContextEvent) {
        if (dataRollbackThread==null){
            dataRollbackThread = new DataRollbackThread();
            dataRollbackThread.start();
        }
    }

    @Override
    public void contextDestroyed(ServletContextEvent servletContextEvent) {
        if (dataRollbackThread != null && dataRollbackThread.isInterrupted()) {
            dataRollbackThread.interrupt();
        }
    }
}